<?php

{$AUTO_GENERATOR_INCLUDE_HEADER_TEMPLATE}

defined('_JEXEC') or die;

class {$AUTO_GENERATOR_COMPONENT|capitalize}View{$AUTO_GENERATOR_VIEWS|capitalize} extends JViewLegacy {

    protected $items;
    protected $pagination;
    protected $state;

    public function display($tpl = null) {
        {$AUTO_GENERATOR_COMPONENT|capitalize}Helper::addSubmenu('{$AUTO_GENERATOR_VIEWS|lower}');

        $this->items = $this->get('Items');
        
        $this->pagination = $this->get('Pagination');
        
        $this->state = $this->get('State');

        $this->addToolbar();

        $this->addFilter();

        parent::display($tpl);
    }

    protected function addToolbar() {
        JToolbarHelper::title(JText::_('COM_{$AUTO_GENERATOR_COMPONENT|upper}_{$AUTO_GENERATOR_VIEWS|upper}_TITLE'));

        JToolbarHelper::addNew('{$AUTO_GENERATOR_CONTROLLER|lower}.add');
        
        JToolbarHelper::editList('{$AUTO_GENERATOR_CONTROLLER|lower}.edit');
        
        JToolbarHelper::deleteList(JText::_('COM_{$AUTO_GENERATOR_COMPONENT|upper}_{$AUTO_GENERATOR_VIEWS|upper}_MESSAGE_CONFIRM_DELETE'), '{$AUTO_GENERATOR_CONTROLLERS|lower}.delete', 'JTOOLBAR_DELETE');
    }

    protected function addFilter() {
        JHtmlSidebar::setAction('index.php?option=com_{$AUTO_GENERATOR_COMPONENT|lower}&view={$AUTO_GENERATOR_CONTROLLERS|lower}');

        $this->sidebar = JHtmlSidebar::render();
    }

    protected function getSortFields() {
        return array(
            '{$AUTO_GENERATOR_PRIMARY_KEY_FIELD}' => JText::_('JGRID_HEADING_ID')
        );
    }

}
